/**
 * 
 */
$(document).ready(function()
		{
	$('input[type=file]').bootstrapFileInput();
	$('.file-inputs').bootstrapFileInput();
	ekManage(1);
		});

var pageNum = 1;
function ekQuery()
{
	var name = $("#ektext").val();
	$.ajax({
		url:'../ekquery.action',
		type:'post',
		dataType:'json',
		data:{Info:name},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{

				var array = eval("(" + result.array + ")");
				// alert(array);
				var html = "";
				$
				.each(
						array,
						function(i, value) {
							// alert(JSON.stringify(value));
							html += "<tr>"
								+ "<td>"
								+ "<label>"
								+ "<input type='checkbox' id='blankCheckbox' value="
								+ value.gid
								+ "#"
								+ value.sid
								+ " aria-label='...'>"
								+ "</label>"
								+ "</td>"
								+ "<td>"
								+ value.gname
								+ "</td>"
								+ "<td>"
								+ value.name
								+ "</td>"
								+ "<td>"
								+ "<button type='button' class='btn btn-default' data-toggle='modal' data-target='#ekAdd' onclick = 'ekModify("
								+ JSON.stringify(value)
								+ ")'>修改</button>"
								+ "</td>" + "</tr>";
						});
				$("#examTbody").html(html);
			
				}
			else
				{
				$("#examTbody").html("");
				alert(result.Info);
				}
		}
	})
	}
function ekModify(value) {
	alert(value.sid);
	var html = "<option value = " + value.gid + "#" + value.sid + ">"
			+ value.gname + "</option>";
	$("#ekSelect").html(html);
	$("#ekInput").val(value.name);
	$("#eksubmit").attr("value", "modify");
}
function ekAdd() {
	$.ajax({
		url : '../getGeneral.action',
		type : 'post',
		dataType : 'json',
		data : {},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				var array = eval("(" + result.array + ")");
				var a = "";
				$.each(array, function(i, value) {
					a += "<option value = " + value.id + ">" + value.name
							+ "</option>";
				});
				$("#ekSelect").html(a);
			}
		}
	});
	$("#ekInput").val("");
	$("#eksubmit").attr("value", "add");
}
function ekSubmit() {

	var operation = $("#eksubmit").val();

	// alert($("#ekInput").val());
	var selected = $("#ekSelect").val();
	// alert(JSON.stringify(ekInfo));
	if (operation == "modify") {
		var info = [];

		info = selected.split("#");
		var ekInfo = {
			gid : info[0],
			sid : info[1],
			name : $("#ekInput").val()
		};
		$.ajax({
			url : '../ekModify.action',
			type : 'post',
			dataType : 'json',
			data : {
				Info : JSON.stringify(ekInfo)
			},
			success : function(data) {
				var result = eval("(" + data + ")");
				if (result.flag == "true") {
					$("#ekClose").click();
					ekManage(pageNum);
				} else {
					alert(result.Info);
				}

			}
		})
	} else if (operation == "add") {

		$.ajax({
			url : '../ekadd.action',
			type : 'post',
			dataType : 'json',
			data : {
				Info : JSON.stringify({
					gid : selected,
					name : $("#ekInput").val()
				})
			},
			success : function(data) {
				var result = eval("(" + data + ")");
				if (result.flag == "true") {
					$("#ekClose").click();
					ekManage(pageNum);
				} else {
					alert(result.Info);
				}

			}
		});

	}

}
function ekManage(pageNum) {
	// alert(pageNum);
	$
	.ajax({
		url : '../getAllSub.action',
		type : 'post',
		dataType : 'json',
		data : {
			pageNum : pageNum
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				var array = eval("(" + result.array + ")");
				// alert(array);
				var html = "";
				$
				.each(
						array,
						function(i, value) {
							// alert(JSON.stringify(value));
							html += "<tr>"
								+ "<td>"
								+ "<label>"
								+ "<input type='checkbox' id='blankCheckbox' value="
								+ value.gid
								+ "#"
								+ value.sid
								+ " aria-label='...'>"
								+ "</label>"
								+ "</td>"
								+ "<td>"
								+ value.gname
								+ "</td>"
								+ "<td>"
								+ value.name
								+ "</td>"
								+ "<td>"
								+ "<button type='button' class='btn btn-default' data-toggle='modal' data-target='#ekAdd' onclick = 'ekModify("
								+ JSON.stringify(value)
								+ ")'>修改</button>"
								+ "</td>" + "</tr>";
						});
				$("#examTbody").html(html);
			}
			else
				{
				alert(result.Info);
				$("#examTbody").html(html);
				}
		}
	})
}
function ekDelete() {
	var el = document.getElementById("examTbody").getElementsByTagName("input");
	var Info = "";
	var count = 0;
	for (var i = 0; i < el.length; i++) {
		if ((el[i].type == 'checkbox') && (el[i].checked)) {
			Info += el[i].value + ",";
			count++;
		}
	}
	if (count == 0) {
		alert("请先选择需要删除的选项");
		return;
	}
	$.ajax({
		url : '../ekdelete.action',
		type : 'post',
		dataType : 'json',
		data : {
			Info : Info
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#ekClose").click();
				ekManage(pageNum);
			} else {
				alert(result.Info);
			}
		}
	})
}



//Examplace manage
function epManage(pageNo) {
	$.ajax({
		url:'../getEp.action',
		type:'post',
		dataType:'json',
		data:{pageNum:pageNo},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag == "true")
				{
				var array = eval("(" + result.array + ")");
				var html = "";
//				alert(result.array);
				$.each(array,function(i,value)
						{
					html+= "<tr>" +
							"<td>" +
							"<label>" +
							"<input type='checkbox' id='blankCheckbox' value="+
							value.epId+
							" aria-label='...'>" +
							"</label>" +
							"</td>" +
							"<td>" +
							value.epId +
							"</td>" +
							"<td>" +
							value.epname +
							"</td>" +
							"<td>" +
							value.epAddress +
							"</td>" +
							"<td>" +
							value.epClassNo +
							"</td>" +
							"<td>" +
							value.limitNo +
							"</td>" +
							"<td>" +
							value.province +
							"</td>" +
							"<td>" +
							value.allocatedNo +
							"</td>" +
							"<td>" +
							"<button type='button' class='btn btn-default' data-toggle='modal' data-target='#epAdd' onclick ='epModify("
								+ JSON.stringify(value)
								+ ")'>修改</button>"+
							"</td></tr>"
						});
//				alert(html);
				$("#epTbody").html(html);
				}
			else
				{
				alert(result.Info);
				$("#epTbody").html("");
				}
			
		}
		
	})
}


var epPage = 1;
function epAdd()
{
	$("#epId").val("系统分配");
//	$("#epId").attr("readonly","readonly")
	$("#epname").val("");
	$("#epAddress").val("");
	$("#epClassNo").val("");
	$("#epLimitNo").val("");
	$("#epAllocatedNo").val("0");
	$.ajax({
		url:'../getProvince.action',
		type:'post',
		dataType:'json',
		data:{},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true"){
				var array = eval("("+result.array+")");
				var html="";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.pid + ">" + value.pname
					+ "</option>";
						});
				$("#epPid").html(html);
			}
		}
			
	});
	$("#epsubmit").attr("value","add");
	}
function epModify(data)
{
	$("#epId").val(data.epId);
//	$("#epId").attr("readonly","readonly")
	$("#epname").val(data.epname);
	$("#epAddress").val(data.epAddress);
	$("#epClassNo").val(data.epClassNo);
	$("#epLimitNo").val(data.limitNo);
	$("#epAllocatedNo").val(data.allocatedNo);
	$.ajax({
		url:'../getProvince.action',
		type:'post',
		dataType:'json',
		data:{},
		success:function(data1)
		{
			var result = eval("("+data1+")");
			if(result.flag=="true"){
				var array = eval("("+result.array+")");
				var html="";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.pid + ">" + value.pname
					+ "</option>";
						});
				$("#epPid").html(html);
				$("#epPid").val(data.provinceId)
			}
		}
			
	});
	$("#epsubmit").attr("value","modify");
	}
function epSubmit()
{
	var value = $("#epsubmit").val();
	alert(value);
	if(value=="add")
		{
//		alert($("#epPid").val());
		var Info = {epname:$("#epname").val(),epAddress:$("#epAddress").val(),epClassNo:$("#epClassNo").val(),epLimitNo:$("#epLimitNo").val(),provinceId:$("#epPid").val()};
		alert(JSON.stringify(Info));
		$.ajax({
			url:'../epAdd.action',
			type:'post',
			dataType:'json',
			data:{Info:JSON.stringify(Info)},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag=="true"){
					$("#epClose").click();
					epManage(epPage);
				}
				else
					{
					alert(result.Info);
					}
			}
		});
		}
	else if(value=="modify")
		{
		var Info = {epId:$("#epId").val(),epname:$("#epname").val(),epAddress:$("#epAddress").val(),epClassNo:$("#epClassNo").val(),epLimitNo:$("#epLimitNo").val(),provinceId:$("#epPid").val()};
		alert(JSON.stringify(Info));
		$.ajax({
			url:'../epModify.action',
			type:'post',
			dataType:'json',
			data:{Info:JSON.stringify(Info)},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag=="true"){
					$("#epClose").click();
					epManage(epPage);
				}
				else
					{
					alert(result.Info);
					}
			}
		});
		
		}
	}
function epDelete()
{
	var el = document.getElementById("epTbody").getElementsByTagName("input");
	var Info = "";
	var count = 0;
	for (var i = 0; i < el.length; i++) {
		if ((el[i].type == 'checkbox') && (el[i].checked)) {
			Info += el[i].value + ",";
			count++;
		}
	}
	if (count == 0) {
		alert("请先选择需要删除的选项");
		return;
	}
	$.ajax({
		url : '../epDelete.action',
		type : 'post',
		dataType : 'json',
		data : {
			Info : Info
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#epClose").click();
				epManage(epPage);
			} else {
				alert(result.Info);
			}
		}
	})

	}
function epQuery()
{
	var Info = $("#epQueryText").val();
	$.ajax({
		url:'../epQuery.action',
		type:'post',
		dataType:'json',
		data:{Info:Info},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html="";
				$.each(array,function(i,value)
						{
					html+= "<tr>" +
							"<td>" +
							"<label>" +
							"<input type='checkbox' id='blankCheckbox' value="+
							value.epId+
							" aria-label='...'>" +
							"</label>" +
							"</td>" +
							"<td>" +
							value.epId +
							"</td>" +
							"<td>" +
							value.epname +
							"</td>" +
							"<td>" +
							value.epAddress +
							"</td>" +
							"<td>" +
							value.epClassNo +
							"</td>" +
							"<td>" +
							value.limitNo +
							"</td>" +
							"<td>" +
							value.province +
							"</td>" +
							"<td>" +
							value.allocatedNo +
							"</td>" +
							"<td>" +
							"<button type='button' class='btn btn-default' data-toggle='modal' data-target='#epAdd' onclick ='epModify("
								+ JSON.stringify(value)
								+ ")'>修改</button>"+
							"</td></tr>"
						});
				$("#epTbody").html(html);
				}
		}
	});
	
	}


//考生管理
var esPage = 1;
function esManage(pageNo) {
	$.ajax({
		url:'../getEp.action',
		type:'post',
		dataType:'json',
		data:{pageNum:1},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html = "";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.epId + ">" + value.epname
					+ "</option>";
						});
				$("#esepId").html(html);
				}
		}
	});
	$.ajax({
		url:'../getUserList.action',
		type:'post',
		dataType:'json',
		data:{pageNum:epPage},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.list+")");
				var html = "";
				$.each(array,function(i,value)
						{
					if(value.admitId=="\"null\"")
						{
						value.adminId="";
						}
						html+=
							"<tr><td>"
							+ "<label>"
							+ "<input type='checkbox' id='blankCheckbox' value="+value.userId+" aria-label='...'>"
							+ "</label>"
							+ "</td>"
							+ "<td>"+value.name+"</td>"
							+ "<td>"+value.userId+"</td>"
							+ "<td>"+value.psd+"</td>"
							+ "<td>"+value.id+"</td>"
							+ "<td>"+value.eeid+"</td>"
							+ "<td>"+value.admitId+"</td>"
							+ "<td>"+value.email+"</td>"
							+ "<td>"+value.general+"</td>"
							+ "<td>"+value.subtype+"</td>"
							+ "<td>"+value.state+"</td>"
							+ "<td>"
							+ "<button type='button' class='btn btn-default' data-toggle='modal' data-target='#esAdd' onclick='esModify("+JSON.stringify(value)+")'>修改</button>"
							+ "</td></tr>";
						});
				$("#esTbody").html(html);
				}
			else
				{
				alert(result.Info);
				$("#esTbody").html("");
				}
		}
	});
}
function esQuery()
{
	var userInfo = $("#esQueryText").val();
	$.ajax({
		url:'../esQuery.action',
		type:'post',
		dataType:'json',
		data:{userInfo:userInfo},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.list+")");
				var html = "";
				$.each(array,function(i,value)
						{
					if(value.admitId=="\"null\"")
						{
						value.adminId="";
						}
						html+=
							"<tr><td>"
							+ "<label>"
							+ "<input type='checkbox' id='blankCheckbox' value="+value.userId+" aria-label='...'>"
							+ "</label>"
							+ "</td>"
							+ "<td>"+value.name+"</td>"
							+ "<td>"+value.userId+"</td>"
							+ "<td>"+value.psd+"</td>"
							+ "<td>"+value.id+"</td>"
							+ "<td>"+value.eeid+"</td>"
							+ "<td>"+value.admitId+"</td>"
							+ "<td>"+value.email+"</td>"
							+ "<td>"+value.general+"</td>"
							+ "<td>"+value.subtype+"</td>"
							+ "<td>"+value.state+"</td>"
							+ "<td>"
							+ "<button type='button' class='btn btn-default' data-toggle='modal' data-target='#esAdd' onclick='esModify("+JSON.stringify(value)+")'>修改</button>"
							+ "</td></tr>";
						});
				$("#esTbody").html(html);
				}
			else
				{
				alert(result.Info);
				$("#esTbody").html("");
				}
		}
		
	})
	}
function esSubmit()
{
//	var Info = {userId:$("#userId").val(),psd:$("#psd").val(),eeid:$("#eeid").val(),email:$("#email").val(),general:$("#general").val(),subtype:$("#subtype").val(),state:$("#state").val(),id:$("#id").val()};
//	alert(JSON.stringify(Info));
	var operation = $("#essubmit").val();
	if(operation=="add")
		{
		var Info = {name:$("#userName").val(),userId:$("#userId").val(),psd:$("#psd").val(),eeid:$("#eeid").val(),email:$("#email").val(),general:$("#general").val(),subtype:$("#subtype").val(),state:$("#state").val(),id:$("#id").val()};
		$.ajax({
			url:'../esAdd.action',
			type:'post',
			dataType:'json',
			data:{userInfo:JSON.stringify(Info)},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag == "true")
					{
					esManage(esPage);
					$("#esClose").click();
					}
				else
					{
					alert(result.Info);
					}
			}
		})
		}
	else
		{
		var Info = {name:$("#userName").val(),userId:$("#userId").val(),psd:$("#psd").val(),eeid:$("#eeid").val(),email:$("#email").val(),userGeneralType:$("#general").val(),userSubType:$("#subtype").val(),state:$("#state").val(),id:$("#id").val()};
		$.ajax({
			url:'../esModify.action',
			type:'post',
			dataType:'json',
			data:{userInfo:JSON.stringify(Info)},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag == "true")
					{
					esManage(esPage);
					$("#esClose").click();
					}
				else
					{
					alert(result.Info);
					}
			}
		})
		}
	}
function esAdd(){
	$("#userId").val("");
	$("#userId").attr("placeholder","不填默认为邮箱");
	$("#psd").attr("placeholder","不填系统自动分配");
	$("#psd").val("");
	$("#eeid").val("");
	$("#email").val("");
	$("#id").val("");
	$("#userName").val("");
	$("#essubmit").attr("value","add");
	$.ajax({
		url : '../getGeneral.action',
		type : 'post',
		dataType : 'json',
		data : {},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				var array = eval("(" + result.array + ")");
				var a = "";
				$.each(array, function(i, value) {
					a += "<option value = " + value.id + ">"
							+ value.name + "</option>";
				});
				$("#general").html(a);
				var selected = $("#general").val();
				$.ajax({
					url : '../getSub.action',
					type : 'post',
					dataType : 'json',
					data : {
						gid : selected
					},
					success : function(data1) {
						var result1 = eval("(" + data1 + ")");
						if (result1.flag == "true") {
							var array1 = eval("(" + result1.array
									+ ")");
							var html = "";
							$.each(array1, function(i, value) {
								html += "<option value = "
										+ value.sid + ">"
										+ value.name + "</option>";
							});
							$("#subtype").html(html);
						}

					}

				});
			}
		}
	});
}
function esModify(userInfo)
{
	$("#userId").val(userInfo.userId);
	$("#userName").val(userInfo.name);
	$("#psd").val(userInfo.psd);
	$("#eeid").val(userInfo.eeid);
	$("#email").val(userInfo.email);
	$("#id").val(userInfo.id);
	$("#state").val(userInfo.state);
	$("#essubmit").attr("value","modify");
	$.ajax({
		url : '../getGeneral.action',
		type : 'post',
		dataType : 'json',
		data : {},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				var array = eval("(" + result.array + ")");
				var a = "";
				$.each(array, function(i, value) {
					a += "<option value = " + value.id + ">"
							+ value.name + "</option>";
				});
				$("#general").html(a);
				$("#general").val(userInfo.userGeneralType);
				var selected = $("#general").val();
				$.ajax({
					url : '../getSub.action',
					type : 'post',
					dataType : 'json',
					data : {
						gid : selected
					},
					success : function(data1) {
						var result1 = eval("(" + data1 + ")");
						if (result1.flag == "true") {
							var array1 = eval("(" + result1.array
									+ ")");
							var html = "";
							$.each(array1, function(i, value) {
								html += "<option value = "
										+ value.sid + ">"
										+ value.name + "</option>";
							});
							$("#subtype").html(html);
							$("#subtype").val(userInfo.userSubType);
						}

					}

				});
			}
		}
	});

	}
function esChange()
{
				var selected = $("#general").val();
				$
						.ajax({
							url : '../getSub.action',
							type : 'post',
							dataType : 'json',
							data : {
								gid : selected
							},
							success : function(data1) {
								var result1 = eval("(" + data1 + ")");
								if (result1.flag == "true") {
									var array1 = eval("("
											+ result1.array + ")");
									var html = "";
									$.each(array1, function(i, value) {
										html += "<option value = "
												+ value.sid + ">"
												+ value.name
												+ "</option>";
									});
									$("#subtype").html(html);
								}

							}

						});
			}
function esDelete()
{
	var el = document.getElementById("esTbody").getElementsByTagName("input");
	var Info = "";
	var count = 0;
	for (var i = 0; i < el.length; i++) {
		if ((el[i].type == 'checkbox') && (el[i].checked)) {
			Info += el[i].value + ",";
			count++;
		}
	}
	if (count == 0) {
		alert("请先选择需要删除的选项");
		return;
	}
	$.ajax({
		url : '../esDelete.action',
		type : 'post',
		dataType : 'json',
		data : {
			userInfo : Info
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#esClose").click();
				esManage(esPage);
			} else {
				alert(result.Info);
			}
		}
	})

	
	}
function esAllocateAI()
{
	$.ajax({
		url : '../esAllocateAI.action',
		type : 'post',
		dataType : 'json',
		data : {},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#esClose").click();
				esManage(epPage);
			} else {
				alert(result.Info);
			}
		}
	})
	}
function esAllocateEP(){
	$.ajax({
		url:'../allocateEp.action',
		type:'post',
		dataType:'json',
		data:{},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				esChange(esPage);
				}
			else
				{
				alert(result.Info);
				}
		}
	})
}
function esCheck(){

	var el = document.getElementById("esTbody").getElementsByTagName("input");
	var Info = "";
	var count = 0;
	for (var i = 0; i < el.length; i++) {
		if ((el[i].type == 'checkbox') && (el[i].checked)) {
			Info += el[i].value + ",";
			count++;
		}
	}
	if (count == 0) {
		alert("请先选择需要审查的选项");
		return;
	}
	$.ajax({
		url : '../esChangeState.action',
		type : 'post',
		dataType : 'json',
		data : {
			userInfo : Info
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#esClose").click();
				esManage(epPage);
			} else {
				alert(result.Info);
			}
		}
	})
}
function importScore()
{
	$.ajaxFileUpload({  
        url:'../excelUpload.action',//用于文件上传的服务器端请求地址  
        secureuri:false,//一般设置为false  
        fileElementId:'scorefile',//文件上传空间的id属性  
        dataType: 'json',//返回值类型 一般设置为json  
        data:{className:'Score'},  
        success: function (data,status) {
        	alert(data.result);
        	var result = eval("(" + data.result+ ")");
        	alert(result.message);
        },  
        error: function (data, status, e) {  
             alert(data.msg);  
             alert(e);  
        }  
    })  
}
function esExport()
{
	var select = $("#esepId").val();
	location.href="../ExcelDownload.action?className=User&epId="+select;
}
function esImport(){

	$.ajaxFileUpload({  
        url:'../excelUpload.action',//用于文件上传的服务器端请求地址  
        secureuri:false,//一般设置为false  
        fileElementId:'esfile',//文件上传空间的id属性  
        dataType: 'json',//返回值类型 一般设置为json  
        data:{className:'Users',epId:$("#esepId").val()},  
        success: function (data,status) {
        	alert(data.result);
        	var result = eval("(" + data.result+ ")");
        	alert(result.message);
        },  
        error: function (data, status, e) {  
             alert(data.msg);  
             alert(e);  
        }  
    })  

}

//专家管理
var proPage = 1;
function proManage(pageNo) {
	$.ajax({
		url:'../proGetList.action',
		type:'post',
		dataType:'json',
		data:{pageNum:pageNo},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html="";
				$.each(array,function(i,value)
						{
					if(value.epClassId=="\"null\"")
						value.epClassId = "";
					html+=
						"<tr><td><label>" +
							"<input type='checkbox'id='blankCheckbox' value="+value.expertId+" aria-label='...'></label></td>" +
							"<td>" +
							value.expertId +
							"</td><td>" +
							value.password +
							"</td><td>" +
							value.expertName +
							"</td><td>" +
							value.email +
							"</td><td>" +
							value.epname +
							"</td><td>" +
							value.epClassId +
							"</td><td>" +
							"<button type='button' class='btn btn-default'data-toggle='modal' data-target='#proAdd' onclick = 'proModify("+JSON.stringify(value)+")'>修改</button>" +
							"</td></tr>";
						});
				$("#proTbody").html(html);
				
				}
			else
				{
				$("#proTbody").html("");
				alert(result.Info);
				}
		}
	});

}
function proAdd()
{
	$("#proId").val("");
	$("#proPsd").val("");
	$("#proName").val("");
	$("#proEmail").val("");
	$("#prosubmit").attr("value","add");
	$("#proEpid").html("<option value =''>考点系统分配</option>");
	$("#proEpid").attr("disabled","disabled");
//	$.ajax({
//		url:'../getEp.action',
//		type:'post',
//		dataType:'json',
//		data:{pageNum:1},
//		success:function(data)
//		{
//			var result = eval("("+data+")");
//			if(result.flag=="true")
//				{
//				var array = eval("("+result.array+")");
//				var html = "";
//				$.each(array,function(i,value)
//						{
//					html+="<option value = " + value.epId + ">" + value.epname
//					+ "</option>";
//						});
//				$("#proEpid").html(html);
//				}
//		}
//	});
	}
function proModify(proInfo)
{
//	alert($("#proName").val());
	$("#proId").val(proInfo.expertId);
	$("#proPsd").val(proInfo.password);
	$("#proName").val(proInfo.expertName);
	$("#proEmail").val(proInfo.email);
	$("#prosubmit").attr("value","modify");
//	alert($("#proName").val());
//	alert(proInfo.epId);
	if(proInfo.epId=="\"null\"")
		{
		$("#proEpid").html("<option value =''>系统未分配，无法修改</option>");
		$("#proEpid").attr("disabled","disabled");
		}
	else
		{
		$.ajax({
			url:'../getEp.action',
			type:'post',
			dataType:'json',
			data:{pageNum:1},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag=="true")
					{
					var array = eval("("+result.array+")");
					var html = "";
					$.each(array,function(i,value)
							{
						html+="<option value = " + value.epId + ">" + value.epname
						+ "</option>";
							});
					$("#proEpid").html(html);
					$("#proEpid").val(proInfo.epId);
					}
			}
		});
		}
	
	
	
	}

function proSubmit()
{
	var operation = $("#prosubmit").val();
	if(operation=="add")
		{
		var Info = {expertId:$("#proId").val(),password:$("#proPsd").val(),email:$("#proEmail").val(),expertName:$("#proName").val()};//,epId:$("#proEpid").val()
		alert(Info);
		$.ajax({
			url:'../proAdd.action',
			type:'post',
			dataType:'json',
			data:{Info:JSON.stringify(Info)},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag=="true")
					{
					proManage(proPage);
					$("#proClose").click();
					}
			}
		})
		}
	else if(operation=="modify")
		{
		var Info = {expertId:$("#proId").val(),password:$("#proPsd").val(),email:$("#proEmail").val(),expertName:$("#proName").val(),epId:$("#proEpid").val()};
		alert(JSON.stringify(Info));
		$.ajax({
			url:'../proModify.action',
			type:'post',
			dataType:'json',
			data:{Info:JSON.stringify(Info)},
			success:function(data)
			{
				var result = eval("("+data+")");
				if(result.flag=="true")
					{
					proManage(proPage);
					$("#proClose").click();
					}
				else
					{
					alert(result.Info);
					}
			}
		})
		
		}
}
function proDelete()
{

	var el = document.getElementById("proTbody").getElementsByTagName("input");
	var Info = "";
	var count = 0;
	for (var i = 0; i < el.length; i++) {
		if ((el[i].type == 'checkbox') && (el[i].checked)) {
			Info += el[i].value + ",";
			count++;
		}
	}
	if (count == 0) {
		alert("请先选择需要删除的选项");
		return;
	}
	$.ajax({
		url : '../proDelete.action',
		type : 'post',
		dataType : 'json',
		data : {
			Info : Info
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#proClose").click();
				proManage(proPage);
			} else {
				alert(result.Info);
			}
		}
	})

	
	
	}
function proQuery(){
	var proName = $("#queryName").val();
	$.ajax({
		url:'../proQuery.action',
		type:'post',
		dataType:'json',
		data:{Info:proName},
		success:function (data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array  = eval("("+result.array+")");
				var html="";
				$.each(array,function(i,value)
						{
					if(value.epClassId=="\"null\"")
						value.epClassId = "";
					html+=
						"<tr><td><label>" +
							"<input type='checkbox'id='blankCheckbox' value="+value.expertId+" aria-label='...'></label></td>" +
							"<td>" +
							value.expertId +
							"</td><td>" +
							value.password +
							"</td><td>" +
							value.expertName +
							"</td><td>" +
							value.email +
							"</td><td>" +
							value.epname +
							"</td><td>" +
							value.epClassId +
							"</td><td>" +
							"<button type='button' class='btn btn-default'data-toggle='modal' data-target='#proAdd' onclick = 'proModify("+JSON.stringify(value)+")'>修改</button>" +
							"</td></tr>";
						});
				$("#proTbody").html(html);
				}
			else
				{
				$("#proTbody").html("");
				alert(result.Info);
				}
		}
	})
	
	
}
function proAllocate()
{
	$.ajax({
		url:'../proAllocate.action',
		type:'post',
		dataType:'json',
		data:{},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
					proManage(proPage);
				}
			else
				{
				alert(result.Info);
				}
		}
	})
	}


//移动管理员manage
var mobPage = 1;
function mobManage(pageNo) {
	$.ajax({
		url:'../getEp.action',
		type:'post',
		dataType:'json',
		data:{pageNum:1},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html = "";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.epname + ">" + value.epname
					+ "</option>";
						});
				$("#mobepId").html(html);
				}
		}
	});
	$.ajax({
		url:'../getMAList.action',
		type:'post',
		dataType:'json',
		data:{pageNum:pageNo},
		success:function(data)
		{
			var result = eval("("+data+")");
			var html="";
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				$.each(array,function(i,value)
						{
					html+="<tr><td><label> " +
							"<input type='checkbox' id='blankCheckbox' value="+value.adminId+" aria-label='...'>" +
							"</label></td>" +
							"<td>" +
							value.adminId +
							"</td>" +
							"<td>" +
							value.adminPsd+
							"</td>" +
							"<td>" +
							value.epname +
							"</td>" +
							"<td>" +
							"<button type='button' class='btn btn-default'data-toggle='modal' data-target='#mobAdd' onclick ='mobModify("+JSON.stringify(value)+")' >修改</button>" +
							"</td></tr>"
						});
				$("#mobTbody").html(html);
				}
			else
				{
				$("#mobTbody").html("");
				alert(result.Info);
				}
		}
	})
}
function mobAdd(){
	$("#mobAdminId").val("");
	$("#mobAdminPsd").val("");
	$("#mobsubmit").attr("value","add");
	$.ajax({
		url:'../getEp.action',
		type:'post',
		dataType:'json',
		data:{pageNum:1},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html = "";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.epname + ">" + value.epname
					+ "</option>";
						});
				$("#mobEpid").html(html);
				}
		}
	});

}
function mobModify(Info)
{

	$("#mobAdminId").val(Info.adminId);
	$("#mobAdminPsd").val(Info.adminPsd);
	$("#mobsubmit").attr("value","modify");
	$.ajax({
		url:'../getEp.action',
		type:'post',
		dataType:'json',
		data:{pageNum:1},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html = "";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.epname + ">" + value.epname
					+ "</option>";
						});
				$("#mobEpid").html(html);
				$("#mobEpid").val(Info.epname);
				}
		}
	});


	}
function mobSubmit()
{
	var operation = $("#mobsubmit").val();
	if(operation == "add")
		{
		var Info = {adminId:$("#mobAdminId").val(),adminPsd:$("#mobAdminPsd").val(),epname:$("#mobEpid").val()};
		alert(JSON.stringify(Info));
		$.ajax({
			url:'../mobAdd.action',
			type:'post',
			dataType:'json',
			data:{adminInfo:JSON.stringify(Info)},
			success:function(data){
				var result = eval("("+data+")");
				if(result.flag=="true")
					{
					mobManage(mobPage);
					$("#mobClose").click();
					}
				else
					{
					alert(result.Info);
					}
			}
		})
		}
	else
		{
			var Info = {adminId:$("#mobAdminId").val(),adminPsd:$("#mobAdminPsd").val(),epname:$("#mobEpid").val()};
			$.ajax({
				url:'../mobModify.action',
				type:'post',
				dataType:'json',
				data:{adminInfo:JSON.stringify(Info)},
				success:function(data){
					var result = eval("("+data+")");
					if(result.flag=="true")
						{
							mobManage(mobPage);
						$("#mobClose").click();
						}
					else
						{
						alert(result.Info);
						}
				}
			})
		}
	}
function mobAllocate()
{
	$.ajax(
			{
				url:'../mobAllocate.action',
				type:'post',
				dataType:'json',
				data:{},
				success:function(data)
				{
					var result = eval("("+data+")");
					if(result.flag=="true")
						{
						mobManage(mobPage);
						}
					else
						{
						alert(result.Info);
						}
				}
			})
	}
function mobDelete()
{

	var el = document.getElementById("mobTbody").getElementsByTagName("input");
	var Info = "";
	var count = 0;
	for (var i = 0; i < el.length; i++) {
		if ((el[i].type == 'checkbox') && (el[i].checked)) {
			Info += el[i].value + ",";
			count++;
		}
	}
	if (count == 0) {
		alert("请先选择需要删除的选项");
		return;
	}
	$.ajax({
		url : '../mobDelete.action',
		type : 'post',
		dataType : 'json',
		data : {
			adminInfo : Info
		},
		success : function(data) {
			var result = eval("(" + data + ")");
			if (result.flag == "true") {
				$("#mobClose").click();
				mobManage(epPage);
			} else {
				alert(result.Info);
			}
		}
	})

	
	}
function exportAdmin(){

	var select = $("#mobepId").val();
	
	location.href="../ExcelDownload.action?className=mAdmin&epId="+select;
}
function exportAllAdmin()
{
	location.href="../ExcelDownloadAll.action?className=mAdmin";
	}
function queryMob(){
	var text = $("#mobQuery").val();
	$.ajax({
		url:'../mobQuery.action',
		type:'post',
		dataType:'json',
		data:{adminInfo:text},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html="";
				$.each(array,function(i,value)
						{
					html+="<tr><td><label> " +
							"<input type='checkbox' id='blankCheckbox' value="+value.adminId+" aria-label='...'>" +
							"</label></td>" +
							"<td>" +
							value.adminId +
							"</td>" +
							"<td>" +
							value.adminPsd+
							"</td>" +
							"<td>" +
							value.epname +
							"</td>" +
							"<td>" +
							"<button type='button' class='btn btn-default'data-toggle='modal' data-target='#mobAdd' onclick ='mobModify("+JSON.stringify(value)+")' >修改</button>" +
							"</td></tr>"
						});
				$("#mobTbody").html(html);
				}
			else
				{
				alert(result.Info);
				$("#mobTbody").html("");
				}
		}
	});
}
function dataManage()
{
	$.ajax({
		url:'../getEp.action',
		type:'post',
		dataType:'json',
		data:{pageNum:1},
		success:function(data)
		{
			var result = eval("("+data+")");
			if(result.flag=="true")
				{
				var array = eval("("+result.array+")");
				var html = "";
				$.each(array,function(i,value)
						{
					html+="<option value = " + value.epId+"#"+value.epname+ ">" + value.epname
					+ "</option>";
						});
				$("#data1epId").html(html);
				$("#data2epId").html(html);
				}
		}
	});
}
function userDownload()
{
	var select = $("#data1epId").val();
	var Info = [];
	Info = select.split("#");
	location.href="../ExcelDownload.action?className=User&epId="+Info[0];
}
function expertDownload()
{

	var select = $("#data1epId").val();
	var Info = [];
	Info = select.split("#");
	location.href="../ExcelDownload.action?className=Expert&epId="+Info[0];

	}
function mAdminDownload()
{
	var select = $("#data1epId").val();
	var Info = [];
	Info = select.split("#");
	location.href="../ExcelDownload.action?className=mAdmin&epId="+Info[1];
}
function epDownload()
{

	var select = $("#data1epId").val();
	var Info = [];
	Info = select.split("#");
	location.href="../ExcelDownload.action?className=Classroom&epId="+Info[0];

	}
function userUpload()
{
	$.ajaxFileUpload({  
        url:'../excelUpload.action',//用于文件上传的服务器端请求地址  
        secureuri:false,//一般设置为false  
        fileElementId:'es1file',//文件上传空间的id属性  
        dataType: 'json',//返回值类型 一般设置为json  
        data:{className:'Users',epId:$("#esepId").val()},  
        success: function (data,status) {
        	alert(data.result);
        	var result = eval("(" + data.result+ ")");
        	alert(result.message);
        },  
        error: function (data, status, e) {  
             alert(data.msg);  
             alert(e);  
        }  
    });
}
function scoreUpload()
{
	$.ajaxFileUpload({  
        url:'../excelUpload.action',//用于文件上传的服务器端请求地址  
        secureuri:false,//一般设置为false  
        fileElementId:'score1file',//文件上传空间的id属性  
        dataType: 'json',//返回值类型 一般设置为json  
        data:{className:'Score'},  
        success: function (data,status) {
        	alert(data.result);
        	var result = eval("(" + data.result+ ")");
        	alert(result.message);
        },  
        error: function (data, status, e) {  
             alert(data.msg);  
             alert(e);  
        }  
    });
}
